<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
</head>
<body>
<script>
    $(function () {

        console.log('${pageContext.session.getAttribute("user")}')

        if ("${pageContext.session.getAttribute("user")}" === "admin") {
            $("#hidden_div").show();
        }

        $("#btn_UserManage").click(function () {
            window.location.href = "${pageContext.request.contextPath}/user/allUser";
        })
    })
</script>

<div class="container">

    <div class="row clearfix">
        <div class="col-md-12-column">
            <div class="page-header">
                <h1>
                    <small>书籍列表----显示所有书籍</small>
                </h1>
            </div>
        </div>

        <div id="hidden_div" class="row clearfix" hidden="hidden">
            <div class="col-md-4 column">
            </div>
            <div class="col-md-offset-11 column">
                <input id="btn_UserManage" type="button" class="btn btn-primary" value="用户管理">
            </div>
        </div>

        <br>

        <div class="row">
            <div class="col-md-4 column">
                <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddBook">新增</a>
            </div>
            <div class="col-md-offset-9 column">
                <form class="form-inline" action="${pageContext.request.contextPath}/book/QueryBookByName"
                      method="post">
                    <input type="text" class="form-control" placeholder="请输入要查询的书名" name="queryBookName">
                    <input type="submit" class="btn btn-primary" value="查询">
                </form>
            </div>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-12-column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>书籍编号</th>
                    <th>书籍名字</th>
                    <th>书籍数量</th>
                    <th>书籍详情</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="book" items="${requestScope.get('list')}">
                    <tr>
                        <td>${book.bookID}</td>
                        <td>${book.bookName}</td>
                        <td>${book.bookCounts}</td>
                        <td>${book.detail}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/book/toUpdate?id=${book.bookID}">修改</a>
                            &nbsp; | &nbsp;
                            <a href="${pageContext.request.contextPath}/book/deleteBook/${book.bookID}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>

</div>

</body>
</html>
